package ch.penas.business.service;

import java.io.Serializable;
import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.faces.model.SelectItem;
import javax.persistence.Query;


import org.primefaces.event.DateSelectEvent;
import org.primefaces.event.ScheduleEntrySelectEvent;
import org.primefaces.model.DefaultScheduleEvent;
import org.primefaces.model.DefaultScheduleModel;
import org.primefaces.model.LazyScheduleModel;
import org.primefaces.model.ScheduleEvent;
import org.primefaces.model.ScheduleModel;

import ch.penas.business.dom.Agenda;
import ch.penas.business.dom.Formateur;
import ch.penas.business.dom.LoginFormateur;
import ch.penas.business.dom.RechercheAgenda;
import ch.penas.business.dom.RechercheFormateur;

/** @author Daniel */
public class AgendaServiceImpl extends AgendaAbstractMYSQL implements
             AgendaService, Serializable {

    /** Serialisation de la class pour une question de securiter. */
    private static final long serialVersionUID = -6797092500849314538L;

    private boolean isTrueEdit = false;

	private RechercheAgenda rechercheAgenda;

    /** Retourne un agenda. */
    private Agenda agenda;

    /** Liste de l'agenda. */
    private List<Agenda> mAgendaList;
    
    private List<Formateur> mSearchFormateurList;

    public List<Formateur> getmSearchFormateurList() {
		return mSearchFormateurList;
	}

	/** Liste temporaire de l'agenda. */
    private List<Agenda> ba;

    /** tempsRechercheAgenda est egal a agenda. */
    private Agenda tempsRechercheAgenda;
    
    private Formateur tempsRechercheFormateur;

    public Formateur getTempsRechercheFormateur() {
		return tempsRechercheFormateur;
	}

	/** eventModel est un model d'evenement
     *  du schedule composant de primefaces. */
    private ScheduleModel eventModel;

    /** lazyEventModel est un model simple d'evenement
     *  du schedule composant de primefaces. */
    private ScheduleModel lazyEventModel;

    /** event est un evenement du schedule composant de primefaces. */
    private ScheduleEvent event = new DefaultScheduleEvent();

    /** Date d'initialisation (Date du jour). */
    private Date maDate;

    private Date StartDateSelectEvent;

    private boolean isTrueTable = true;

    private boolean isTrueSearch = true;

    private boolean isTrueEvent = true;

    /** startHeur. */
    private String startHeur;

    /** endHeur. */
    private String endHeur;

    private String loginUser;

    private boolean loginIsTrue;

    /** final variable dix. */
    private final int dix = 10;

    /** final variable huit. */
    private final int huit = 8;

    /** final variable six. */
    private final int six = 6;

    /** final variable cinq. */
    private final int cinq = 5;

    /** final variable quatre. */
    private final int quatre = 4;

    /** final variable trois. */
    private final int trois = 3;

    private String NomSearchTemps;

	private String PrenomSearchTemps;

    /** Constructeur par défaut de la class AgendaServiceImpl. */
    public AgendaServiceImpl() {
    	this.mSearchFormateurList = new ArrayList<Formateur>();
    	this.rechercheAgenda = new RechercheAgenda();
    	this.tempsRechercheAgenda = new Agenda();
    	this.tempsRechercheFormateur = new Formateur();
        this.agenda = new Agenda();
        this.maDate = new Date();
        this.mAgendaList = new ArrayList<Agenda>();
        eventModel = new DefaultScheduleModel();
        lazyEventModel = new LazyScheduleModel();
        this.ba = new ArrayList<Agenda>();
    }

    /** Permet d'ajouter un evenement a lagenda.
    *
    * @param mAgendaAddEvent est egale a un evenement de lagenda
    */
    @SuppressWarnings("deprecation")
    public final void addEvent(final Agenda mAgendaAddEvent) {
        if (event.getId() == null) {
            if (getStartHeur().length() == this.cinq) {
                Date eventDate = event.getStartDate();

                String stringtHeur = getStartHeur().
                        substring(0, 2);
                int intHeur = Integer.parseInt(stringtHeur);
                eventDate.setHours(intHeur);

                String stringMinute = getStartHeur();
                int separ = stringMinute.indexOf(":");
                String stringMinuteSepar = stringMinute.
                        substring(separ + 1).trim();
                int intMinute = Integer.parseInt(
                        stringMinuteSepar);
                eventDate.setMinutes(intMinute);

                eventModel.addEvent(new DefaultScheduleEvent(
                        event.getTitle(), eventDate,
                        event.getStartDate(), false));

                this.agenda.setSalle(mAgendaAddEvent.getSalle());
                this.agenda.setCommentaire(
                        mAgendaAddEvent.getCommentaire());
                this.agenda.setUser(mAgendaAddEvent.getUser());
                this.agenda.setTitle(event.getTitle());

                SimpleDateFormat formatter = new
                        SimpleDateFormat("dd-MM-yyyy");
                String dateFormatter = formatter.format(
                        event.getStartDate());
                String b = dateFormatter.substring(this.six, this.dix) + '/'
                        + dateFormatter.substring(this.trois, this.cinq)
                        + '/'
                        + dateFormatter.substring(0, 2);

                this.agenda.setStartDate(b);
                this.agenda.setStartHeur(event.getStartDate());
                this.agenda.setEndHeur(mAgendaAddEvent.getEndHeur());
                this.add(this.agenda);

            } else if (getStartHeur().length() == this.quatre) {
                Date eventDate = event.getStartDate();

                String stringtHeur = getStartHeur().
                        substring(0, 1);
                int intHeur = Integer.parseInt(stringtHeur);
                eventDate.setHours(intHeur);
                String stringMinute = getStartHeur();
                int separ = stringMinute.indexOf(":");
                String stringMinuteSepar = stringMinute.
                        substring(separ + 1).trim();
                int intMinute = Integer.
                        parseInt(stringMinuteSepar);
                eventDate.setMinutes(intMinute);

                eventModel.addEvent(new DefaultScheduleEvent(
                        event.getTitle(), eventDate,
                        event.getStartDate(), false));

                this.agenda.setSalle(mAgendaAddEvent.getSalle());
                this.agenda.setCommentaire(
                        mAgendaAddEvent.getCommentaire());
                this.agenda.setUser(mAgendaAddEvent.getUser());
                this.agenda.setTitle(event.getTitle());

                SimpleDateFormat formatter = new
                        SimpleDateFormat("dd-MM-yyyy");
                String dateFormatter = formatter.format(
                        event.getStartDate());
                String b = dateFormatter.substring(this.six, this.dix) + '/'
                        + dateFormatter.substring(this.trois, this.cinq)
                        + '/'
                        + dateFormatter.substring(0, 2);
                this.agenda.setStartDate(b);
                this.agenda.setStartHeur(event.getStartDate());
                this.agenda.setEndHeur(mAgendaAddEvent.getEndHeur());
                this.add(this.agenda);
            }
        } else {
            if (getStartHeur().length() == this.cinq) {
                Date eventDate = event.getStartDate();

                String stringtHeur = getStartHeur().substring(0, 2);
                int intHeur = Integer.parseInt(stringtHeur);
                eventDate.setHours(intHeur);
                String stringMinute = getStartHeur();
                int separ = stringMinute.indexOf(":");
                String stringMinuteSepar = stringMinute.
                       substring(separ + 1).trim();
                int intMinute = Integer.parseInt(stringMinuteSepar);
                eventDate.setMinutes(intMinute);

                eventModel.updateEvent(event);
                this.agenda.setIdPlanning(mAgendaAddEvent.getIdPlanning());
                this.agenda.setUser(mAgendaAddEvent.getUser());
                this.agenda.setTitle(event.getTitle());
                SimpleDateFormat formatter = new
                        SimpleDateFormat("dd-MM-yyyy");
                String dateFormatter = formatter.format(
                        event.getStartDate());
                String b = dateFormatter.substring(this.six, this.dix) + '/'
                        + dateFormatter.substring(this.trois, this.cinq)
                        + '/'
                        + dateFormatter.substring(0, 2);
                this.agenda.setStartDate(b);
                this.agenda.setStartHeur(eventDate);
                this.agenda.setEndHeur(mAgendaAddEvent.getEndHeur());
                this.agenda.setSalle(mAgendaAddEvent.getSalle());
                this.agenda.setCommentaire(mAgendaAddEvent.getCommentaire());
                event = new DefaultScheduleEvent();
                this.update(this.agenda);

        } else if ((getStartHeur().length() == this.quatre)
                  || (mAgendaAddEvent.getIdPlanning() != "")) {
                  Date eventDate = event.getStartDate();

                  String stringtHeur = getStartHeur().substring(0, 1);
                  int intHeur = Integer.parseInt(stringtHeur);
                  eventDate.setHours(intHeur);
                  String stringMinute = getStartHeur();
                  int separ = stringMinute.indexOf(":");
                  String stringMinuteSepar = stringMinute.
                         substring(separ + 1).trim();
                  int intMinute = Integer.parseInt(stringMinuteSepar);
                  eventDate.setMinutes(intMinute);

                  eventModel.updateEvent(event);
                  this.agenda.setIdPlanning(mAgendaAddEvent.getIdPlanning());
                  this.agenda.setUser(mAgendaAddEvent.getUser());
                  this.agenda.setTitle(event.getTitle());
                  SimpleDateFormat formatter = new
                          SimpleDateFormat("dd-MM-yyyy");
                  String dateFormatter = formatter.format(
                          event.getStartDate());
                  String b = dateFormatter.substring(this.six, this.dix) + '/'
                          + dateFormatter.substring(this.trois, this.cinq)
                          + '/'
                          + dateFormatter.substring(0, 2);
                  this.agenda.setStartDate(b);
                  this.agenda.setStartHeur(eventDate);
                  this.agenda.setEndHeur(mAgendaAddEvent.getEndHeur());
                  this.agenda.setSalle(mAgendaAddEvent.getSalle());
                  this.agenda.setCommentaire(mAgendaAddEvent.getCommentaire());
                  this.update(this.agenda);
                  event = new DefaultScheduleEvent();
             }
         }
    }

    /** Permet d'afficher les ellement du planning.
    *
    * @return la liste des evenement du planning
    */
    public final List<Agenda> getAll() {
        if (this.getIsTrueSearch()) {
            if (this.getIsTrueTable()) {
                try {
                    initFixture();
                } catch (Exception e) {
                    e.printStackTrace();
                }
                this.mAgendaList.removeAll(mAgendaList);
                getEntityTransaction().begin();

                Query query = getEntityManager().createQuery(
                "SELECT a FROM Agenda a WHERE a.user='"
                + this.getLoginUser() + "'");

                @SuppressWarnings("unchecked")
                List<Agenda> b = query.getResultList();
                for (Agenda aAgenda : b) {
                    this.tempsRechercheAgenda = aAgenda;
                    this.addRecherche(
                    this.getTempsRechercheAgenda());
                }

                getEntityTransaction().commit();

                try {
                    closeEntityManager();
                } catch (SQLException e) {
                        e.printStackTrace();
                }
                this.setIsTrueTable(false);
            }
        }
             return this.mAgendaList;
    }

    /** Permet de ce loger a son agenda.
    *
    * @param mLoginFormateur est egale au logine entrer
    * pour ce conneter a son agenda
    */
    public final void login(final LoginFormateur mLoginFormateur) {
        try {
             initFixture();
        } catch (Exception e) {
            e.printStackTrace();
        }
        getEntityTransaction().begin();

        Query query = getEntityManager().createQuery(
                "SELECT e FROM Formateur e");

        @SuppressWarnings("unchecked")
        List<Formateur> b = query.getResultList();
        for (Formateur aAgenda : b) {
            if ((mLoginFormateur.getUser().equals(aAgenda.getUser()))
               &&
               (mLoginFormateur.getPassword().equals(aAgenda.getPassword()))) {
                this.setLoginIsTrue(true);
                this.setLoginUser(aAgenda.getUser());
            } else {
              System.out.println();
            }
        }

        getEntityTransaction().commit();

        try {
            closeEntityManager();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

    /** Permet d'ajouter un evenement a la base de donnée SQL.
    *
    * @param mAgendaAdd est egal a un evenement de l'agenda
    * a ajouter a la base de donnée SQL
    */
    public final void add(final Agenda mAgendaAdd) {
        try {
            initFixture();

            getEntityTransaction().begin();
            getEntityManager().persist(mAgendaAdd);
            getEntityTransaction().commit();

            this.setIsTrueTable(true);

            closeEntityManager();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if((this.getLoginUser().equals("admin")) || (this.getLoginUser().equals("respForma"))){
        	this.rechercheAgenda.setSearchNom(this.getNomSearchTemps());
            this.rechercheAgenda.setSearchPrenom(this.getPrenomSearchTemps());
            this.search(this.rechercheAgenda);
        } else {
        	this.setIsTrueTable(true);
        }
    }

    /** Permet de supprimer un evenement de la base de donnée SQL.
    *
    * @param mAgendaDel est egale a un evenement de l'agenda
    * a supprimer de la base de donnée SQL
    */
    public final void del(final Agenda mAgendaDel) {
        try {
            initFixture();

            getEntityTransaction().begin();
            Agenda userx = getEntityManager().find(
                   Agenda.class, mAgendaDel.getIdPlanning());
            getEntityManager().remove(userx);
            getEntityTransaction().commit();

            closeEntityManager();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if((this.getLoginUser().equals("admin")) || (this.getLoginUser().equals("respForma"))){
        	this.rechercheAgenda.setSearchNom(this.getNomSearchTemps());
            this.rechercheAgenda.setSearchPrenom(this.getPrenomSearchTemps());
            this.search(this.rechercheAgenda);
        } else {
        	this.setIsTrueTable(true);
        }
    }

    /** Permet de modifier un evenement de la base de donnée SQL.
    *
    * @param mAgendaUpd est egale a un evenement de l'agenda
    * a modifier de la base de donnée SQL
    */
    public final void update(final Agenda mAgendaUpd) {
       try {
            initFixture();

            getEntityTransaction().begin();
            Agenda genre = getEntityManager().find(
            Agenda.class, mAgendaUpd.getIdPlanning());

            if (mAgendaUpd.getUser() != "") {
                genre.setUser(mAgendaUpd.getUser());
            }
            if (mAgendaUpd.getTitle() != "") {
                genre.setTitle(mAgendaUpd.getTitle());
            }
            if (mAgendaUpd.getStartDate() != "") {
                genre.setStartDate(mAgendaUpd.getStartDate());
            }
            if (mAgendaUpd.getStartHeur() != "") {
                SimpleDateFormat formatter = new
                        SimpleDateFormat("HH:mm");
                Date s = formatter.parse(
                        mAgendaUpd.getStartHeur());
                genre.setStartHeur(s);
            }
            if (mAgendaUpd.getEndHeur() != "") {
                genre.setEndHeur(mAgendaUpd.getEndHeur());
            }
            if (mAgendaUpd.getSalle() != "") {
                genre.setSalle(mAgendaUpd.getSalle());
            }
            if (mAgendaUpd.getCommentaire() != "") {
                genre.setCommentaire(mAgendaUpd.getCommentaire());
            }
            getEntityTransaction().commit();

            this.setIsTrueTable(true);
            this.setTrueSearch(true);

            closeEntityManager();
            } catch (Exception e) {
                e.printStackTrace();
        }

       if((this.getLoginUser().equals("admin")) || (this.getLoginUser().equals("respForma"))){
       	this.rechercheAgenda.setSearchNom(this.getNomSearchTemps());
           this.rechercheAgenda.setSearchPrenom(this.getPrenomSearchTemps());
           this.search(this.rechercheAgenda);
       } else {
       	this.setIsTrueTable(true);
       }
    }

    /** Permet de recuperer la valeur de l'eventModel.
     *
     * @return eventModel est egal a un evenement du schedule
     */
    @SuppressWarnings("deprecation")
    public final ScheduleModel getEventModel() {
        if (this.getIsTrueSearch()) {
        	 eventModel.clear();
        try {
            initFixture();
        } catch (Exception e) {
            e.printStackTrace();
        }
        getEntityTransaction().begin();

        Query query = getEntityManager().createQuery(
                "SELECT a FROM Agenda a WHERE a.user='"
                + this.getLoginUser() + "'");
        @SuppressWarnings("unchecked")
        List<Agenda> queryAgenda = query.getResultList();
        for (Agenda aAgenda : queryAgenda) {
            String as = new String("-");
            String das = new String("/");
            String bla = aAgenda.getStartDate();
            String str = bla.replace(as, das);
            SimpleDateFormat formatter = new
                    SimpleDateFormat("yyyy/MM/dd");
            Date s;
            try {
                 if (aAgenda.getStartHeur().length() == this.huit) {
                    s = formatter.parse(str);
                    String p = aAgenda.getStartHeur().
                            substring(0, 2);
                    int g = Integer.parseInt(p);
                    s.setHours(g);

                    String pa = aAgenda.getStartHeur().
                            substring(this.trois, this.cinq);
                    int pas = Integer.parseInt(pa);
                    s.setMinutes(pas);

                    eventModel.addEvent(new
                            DefaultScheduleEvent(
                                    aAgenda.getTitle(),
                                    s, s, false));//aAgenda == getIdPlanning
                } else {
                    s = formatter.parse(str);
                    String p = aAgenda.getStartHeur().
                            substring(0, 1);
                    int g = Integer.parseInt(p);
                    s.setHours(g);

                    eventModel.addEvent(new
                            DefaultScheduleEvent(
                            aAgenda.getTitle(),
                            s, s, false));
                }
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }

        getEntityTransaction().commit();

        try {
            closeEntityManager();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        }
        return eventModel;
    }

    public void searchFormateurPourAgenda(RechercheFormateur mRechercheutilisateur) {
		try {
            initFixture();
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.mSearchFormateurList.removeAll(mSearchFormateurList);
        getEntityTransaction().begin();

        Query query = getEntityManager().createQuery(
        "SELECT f FROM Formateur f, Competence c, FormateurCompetence fc " +
        "WHERE f.idUtilisateur = fc.idFormateur " +
        "AND c.idCompetence = fc.idCompetence " +
        "AND c.titre = '" + mRechercheutilisateur.getSearchCompetence() + "'");

        @SuppressWarnings("unchecked")
        List<Formateur> b = query.getResultList();
        for (Formateur aFormateur : b) {
            this.tempsRechercheFormateur = aFormateur;
            this.addRechercheFormateur(this.getTempsRechercheFormateur());
        }

        getEntityTransaction().commit();

        try {
            closeEntityManager();
        } catch (SQLException e) {
                e.printStackTrace();
        }
	}

    /** Permet de rechercher un un formateur étant dans l'agenda.
     *
     * @param mRechercheAgenda est egal au formateur de la recherche
     */
    public final void search(final RechercheAgenda mRechercheAgenda) {
        this.setTrueSearch(false);
        this.mAgendaList.removeAll(mAgendaList);
        eventModel.clear();
        this.ba.removeAll(ba);

        if (mRechercheAgenda.getSearchNom() != null) {
            try {
                initFixture();
            } catch (Exception e) {
                e.printStackTrace();
            }
            getEntityTransaction().begin();

            if (mRechercheAgenda.getSearchNom() != null) {
            	Query query = getEntityManager().createQuery(
                "SELECT a FROM Agenda a, Formateur f "
            	+ "WHERE f.user = a.user "
            	+ "AND f.nom='" + mRechercheAgenda.getSearchNom() + "'"
                + "AND f.prenom='" + mRechercheAgenda.getSearchPrenom() + "'");
                this.ba = query.getResultList();
                this.setNomSearchTemps(mRechercheAgenda.getSearchNom());
                this.setPrenomSearchTemps(mRechercheAgenda.getSearchPrenom());
            } else {
            	Query query2 = getEntityManager().createQuery(
                "SELECT a FROM Agenda a, Formateur f "
                + "WHERE f.user = a.user "
                + "AND f.nom='" + mRechercheAgenda.getSearchNom() + "'"
                + "AND f.prenom='" + mRechercheAgenda.getSearchPrenom() + "'");
                this.ba = query2.getResultList();
            }
            for (Agenda aAgenda : ba) {
                this.tempsRechercheAgenda = aAgenda;
                this.addRecherche(
                        this.getTempsRechercheAgenda());

                String as = new String("-");
                String das = new String("/");
                String bla = aAgenda.getStartDate();
                String str = bla.replace(as, das);
                SimpleDateFormat formatter = new
                SimpleDateFormat("yyyy/MM/dd");
                Date s;
                try {
                    if (aAgenda.getStartHeur().length() == this.huit) {
                        s = formatter.parse(str);
                        String p = aAgenda.getStartHeur().
                                substring(0, 2);
                        int g = Integer.parseInt(p);
                        s.setHours(g);

                        String pa = aAgenda.getStartHeur().
                                substring(this.trois, this.cinq);
                        int pas = Integer.parseInt(pa);
                        s.setMinutes(pas);

                        eventModel.addEvent(new
                                DefaultScheduleEvent(
                                aAgenda.getTitle(),
                                s, s, false));
                    } else {
                        s = formatter.parse(str);
                        String p = aAgenda.getStartHeur().
                                substring(0, 1);
                        int g = Integer.parseInt(p);
                        s.setHours(g);

                        eventModel.addEvent(new
                                DefaultScheduleEvent(
                                aAgenda.getTitle(),
                                s, s, false));
                    }
                } catch (ParseException e) {
                    e.printStackTrace();
                }
            }
            getEntityTransaction().commit();
            try {
                closeEntityManager();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        } else {
            System.out.println("");
        }
    }

    /** Permet d'ajouter un evenement de l'agenda
     *  a la liste des evenements de l'agenda.
     *
     *  @param mAgendaAddSearch est egale a un evenement de lagenda
     */
    public final void addRecherche(final Agenda mAgendaAddSearch) {
        this.mAgendaList.add(mAgendaAddSearch);
    }

    public final void addRechercheFormateur(final Formateur mFormateurAddSearch) {
        this.mSearchFormateurList.add(mFormateurAddSearch);
    }

    /** Permet de retourner la liste des evenement de l'agenda.
     *
     * @return tempsRechercheAgenda est egale à
     * la liste des evenement de l'agenda
     */
    public final Agenda getTempsRechercheAgenda() {
        return this.tempsRechercheAgenda;
    }

    /** Permet de selectioner un evenement du schedule.
     *
     * @param aSelectEvent est egale a ScheduleEntrySelectEvent
     */
    public final void onEventSelect(final
    	ScheduleEntrySelectEvent aSelectEvent) {
    	this.setTrueEdit(true);
        event = aSelectEvent.getScheduleEvent();
    }

    /** Permet de selectioner une date du schedule.
     *
     * @param aSelectEvent est egale a DateSelectEvent
     */
    public final void onDateSelect(final DateSelectEvent aSelectEvent) {
    	this.setTrueEdit(false);
    	setStartDateSelectEvent(aSelectEvent);
        event = new DefaultScheduleEvent("", getStartDateSelectEvent(),
        getStartDateSelectEvent());
    }

    /** Permet de convertire un String en date.
     *
     * @param aDate est egal au String doner en paramettre a la methode
     * @return la date de aDate convertie en date
     * @throws ParseException gere l'exception
     */
    public static Date stringToDate(final String aDate) throws ParseException {
        SimpleDateFormat formatter = new SimpleDateFormat("dd-MM-yyyy");
        return formatter.parse(aDate);
    }

    /** Permet de modifier la valeur de eventModel.
     *
     * @param aEventModel est egale a eventModel du schedule
     */
    public final void setEventModel(final ScheduleModel aEventModel) {
        this.eventModel = aEventModel;
    }

    /** Permet de recuperer la valeur de lazyEventModel.
     *
     * @return lazyEventModel du schedule
     */
    public final ScheduleModel getLazyEventModel() {
        return lazyEventModel;
    }

    /** Permet de modifier la valeur de lazyEventModel.
     *
     * @param aLazyEventModel est egal a lazyEventModel
     */
    public final void setLazyEventModel(final ScheduleModel aLazyEventModel) {
        this.lazyEventModel = aLazyEventModel;
    }

    /** Permet de recuperer la valeur de l'event.
     *
     * @return event du schedule
     */
    public final ScheduleEvent getEvent() {
        return event;
    }

    /** Permet de modifier la valeur de l'event.
     *
     * @param aEvent est egale a event
     */
    public final void setEvent(final ScheduleEvent aEvent) {
        this.event = aEvent;
    }

    /** Permet de recupéré la date (la date du jour).
     *
     * @return maDate qui est egale a la date du jour
     */
    public final Date getMaDate() {
        return this.maDate;
    }

    /** Permet de modifier la valeur de ma date.
     *
     * @param aMaDate est egal a maDate
     */
    public final void setMaDate(final Date aMaDate) {
        this.maDate = aMaDate;
    }

    /**  Permet de recupéré l'Event selectioner.
     *
     * @return StartDateSelectEvent
     */
    public final Date getStartDateSelectEvent() {
        return StartDateSelectEvent;
    }

    /** Permet de modifier la valeur de l'event selectioner.
     *
     * @param aStartDateSelectEvent est egal a l'event selectioner
     */
    @SuppressWarnings("deprecation")
    public final void setStartDateSelectEvent(
           final DateSelectEvent aStartDateSelectEvent) {
        Date date = aStartDateSelectEvent.getDate();
        date.setDate(date.getDate() + 1);
        StartDateSelectEvent = date;
    }

    /**  Permet de recupéré l'heur.
     *
     * @return startHeur est egal a l'heur
     */
    public final String getStartHeur() {
        return startHeur;
    }
    /** Permet de modifier la valeur de l'heur.
     *
     * @param aStartHeur est egal a l'heur
     */
    public final void setStartHeur(final String aStartHeur) {
        this.startHeur = aStartHeur;
    }

    /**  Permet de recupéré l'heur.
     *
     * @return startHeur est egal a l'heur
     */
    public final String getEndHeur() {
        return endHeur;
    }
    /** Permet de modifier la valeur de l'heur.
     *
     * @param aEndHeur est egal a l'heur de fin
     */
    public final void setEndHeur(final String aEndHeur) {
        this.endHeur = aEndHeur;
    }

    /** Permet de recupéré isTrueTable.
     *
     * @return isTrueTable est egale a isTrueTable
     */
    public final boolean getIsTrueTable() {
        return this.isTrueTable;
    }
    /** Permet de modifier la valeur de isTrueTable.
     *
     * @param aIsTrueTable est egale a isTrueTable
     */
    public final void setIsTrueTable(final boolean aIsTrueTable) {
        this.isTrueTable = aIsTrueTable;
    }

    /** Permet de recupéré isTrueEvent.
     *
     * @return isTrueEvent est egale a isTrueEvent
     */
    public final boolean getIsTrueEvent() {
        return this.isTrueEvent;
    }
    /** Permet de modifier la valeur de isTrueEvent.
     *
     * @param aIsTrueEvent est egale a isTrueEvent
     */
    public final void setIsTrueEvent(final boolean aIsTrueEvent) {
        this.isTrueEvent = aIsTrueEvent;
    }

    /** Permet de recupéré isTrueSearch.
     *
     * @return isTrueSearch est egale a isTrueEvent
     */
    public final boolean getIsTrueSearch() {
        return isTrueSearch;
    }
    /** Permet de modifier la valeur de isTrueSearch.
     *
     * @param aIsTrueSearch est egale a isTrueSearch
     */
    public final void setTrueSearch(final boolean aIsTrueSearch) {
        this.isTrueSearch = aIsTrueSearch;
    }

    /** Permet de recupéré loginIsTrue.
     *
     * @return loginIsTrue est egale a loginIsTrue
     */
    public final boolean getLoginIsTrue() {
        return loginIsTrue;
    }
    /** Permet de modifier la valeur de loginIsTrue.
     *
     * @param aLoginIsTrue est egale a loginIsTrue
     */
    public final void setLoginIsTrue(final boolean aLoginIsTrue) {
        this.loginIsTrue = aLoginIsTrue;
    }

    /** Permet de recupéré le user en cour d'utilisation.
     *
     * @return loginUser qui est egale au user
     */
    public final String getLoginUser() {
        return loginUser;
    }
    /** Permet de modifier la valeur de loginUser.
     *
     * @param aLoginUser est egal a loginUser
     */
    public final void setLoginUser(final String aLoginUser) {
        this.loginUser = aLoginUser;
    }

    public boolean getTrueEdit() {
		return this.isTrueEdit;
	}

	public void setTrueEdit(boolean isTrueEdit) {
		this.isTrueEdit = isTrueEdit;
	}

    public final String getNomSearchTemps() {
		return this.NomSearchTemps;
	}

	public final void setNomSearchTemps(final String nomSearchTemps) {
		NomSearchTemps = nomSearchTemps;
	}

	public final String getPrenomSearchTemps() {
		return PrenomSearchTemps;
	}

	public final void setPrenomSearchTemps(final String prenomSearchTemps) {
		PrenomSearchTemps = prenomSearchTemps;
	}

    /** Permet d'ajouter les heur du jour.
     *
     * @return startHeur l'heur du debu de l'evenement
     */
    public final List<SelectItem> getValuesStartHeur() {
        List<SelectItem> startHeurList = new ArrayList<SelectItem>();
        startHeurList.add(new SelectItem("00:30", "00:30"));
        startHeurList.add(new SelectItem("1:00", "1:00"));
        startHeurList.add(new SelectItem("1:30", "1:30"));
        startHeurList.add(new SelectItem("2:00", "2:00"));
        startHeurList.add(new SelectItem("2:30", "2:30"));
        startHeurList.add(new SelectItem("3:00", "3:00"));
        startHeurList.add(new SelectItem("3:30", "3:30"));
        startHeurList.add(new SelectItem("4:00", "4:00"));
        startHeurList.add(new SelectItem("4:30", "4:30"));
        startHeurList.add(new SelectItem("5:00", "5:00"));
        startHeurList.add(new SelectItem("5:30", "5:30"));
        startHeurList.add(new SelectItem("6:00", "6:00"));
        startHeurList.add(new SelectItem("6:30", "6:30"));
        startHeurList.add(new SelectItem("7:00", "7:00"));
        startHeurList.add(new SelectItem("7:30", "7:30"));
        startHeurList.add(new SelectItem("8:00", "8:00"));
        startHeurList.add(new SelectItem("8:30", "8:30"));
        startHeurList.add(new SelectItem("9:00", "9:00"));
        startHeurList.add(new SelectItem("9:30", "9:30"));
        startHeurList.add(new SelectItem("10:00", "10:00"));
        startHeurList.add(new SelectItem("10:30", "10:30"));
        startHeurList.add(new SelectItem("11:00", "11:00"));
        startHeurList.add(new SelectItem("11:30", "11:30"));
        startHeurList.add(new SelectItem("12:00", "12:00"));
        startHeurList.add(new SelectItem("12:30", "12:30"));
        startHeurList.add(new SelectItem("13:00", "13:00"));
        startHeurList.add(new SelectItem("13:30", "13:30"));
        startHeurList.add(new SelectItem("14:00", "14:00"));
        startHeurList.add(new SelectItem("14:30", "14:30"));
        startHeurList.add(new SelectItem("15:00", "15:00"));
        startHeurList.add(new SelectItem("15:30", "15:30"));
        startHeurList.add(new SelectItem("16:00", "16:00"));
        startHeurList.add(new SelectItem("16:30", "16:30"));
        startHeurList.add(new SelectItem("17:00", "17:00"));
        startHeurList.add(new SelectItem("17:30", "17:30"));
        startHeurList.add(new SelectItem("18:00", "18:00"));
        startHeurList.add(new SelectItem("18:30", "18:30"));
        startHeurList.add(new SelectItem("19:00", "19:00"));
        startHeurList.add(new SelectItem("19:30", "19:30"));
        startHeurList.add(new SelectItem("20:00", "20:00"));
        startHeurList.add(new SelectItem("20:30", "20:30"));
        startHeurList.add(new SelectItem("21:00", "21:00"));
        startHeurList.add(new SelectItem("21:30", "21:30"));
        startHeurList.add(new SelectItem("22:00", "22:00"));
        startHeurList.add(new SelectItem("22:30", "22:30"));
        startHeurList.add(new SelectItem("23:00", "23:00"));
        startHeurList.add(new SelectItem("23:30", "23:30"));
        return startHeurList;
    }

    /** Permet d'ajouter les heur du jour.
     *
     * @return endHeur l'heur de la fin de l'evenement
     */
    public final List<SelectItem> getValuesEndHeur() {
        List<SelectItem> endHeurList = new ArrayList<SelectItem>();
        endHeurList.add(new SelectItem("00:30", "00:30"));
        endHeurList.add(new SelectItem("1:00", "1:00"));
        endHeurList.add(new SelectItem("1:30", "1:30"));
        endHeurList.add(new SelectItem("2:00", "2:00"));
        endHeurList.add(new SelectItem("2:30", "2:30"));
        endHeurList.add(new SelectItem("3:00", "3:00"));
        endHeurList.add(new SelectItem("3:30", "3:30"));
        endHeurList.add(new SelectItem("4:00", "4:00"));
        endHeurList.add(new SelectItem("4:30", "4:30"));
        endHeurList.add(new SelectItem("5:00", "5:00"));
        endHeurList.add(new SelectItem("5:30", "5:30"));
        endHeurList.add(new SelectItem("6:00", "6:00"));
        endHeurList.add(new SelectItem("6:30", "6:30"));
        endHeurList.add(new SelectItem("7:00", "7:00"));
        endHeurList.add(new SelectItem("7:30", "7:30"));
        endHeurList.add(new SelectItem("8:00", "8:00"));
        endHeurList.add(new SelectItem("8:30", "8:30"));
        endHeurList.add(new SelectItem("9:00", "9:00"));
        endHeurList.add(new SelectItem("9:30", "9:30"));
        endHeurList.add(new SelectItem("10:00", "10:00"));
        endHeurList.add(new SelectItem("10:30", "10:30"));
        endHeurList.add(new SelectItem("11:00", "11:00"));
        endHeurList.add(new SelectItem("11:30", "11:30"));
        endHeurList.add(new SelectItem("12:00", "12:00"));
        endHeurList.add(new SelectItem("12:30", "12:30"));
        endHeurList.add(new SelectItem("13:00", "13:00"));
        endHeurList.add(new SelectItem("13:30", "13:30"));
        endHeurList.add(new SelectItem("14:00", "14:00"));
        endHeurList.add(new SelectItem("14:30", "14:30"));
        endHeurList.add(new SelectItem("15:00", "15:00"));
        endHeurList.add(new SelectItem("15:30", "15:30"));
        endHeurList.add(new SelectItem("16:00", "16:00"));
        endHeurList.add(new SelectItem("16:30", "16:30"));
        endHeurList.add(new SelectItem("17:00", "17:00"));
        endHeurList.add(new SelectItem("17:30", "17:30"));
        endHeurList.add(new SelectItem("18:00", "18:00"));
        endHeurList.add(new SelectItem("18:30", "18:30"));
        endHeurList.add(new SelectItem("19:00", "19:00"));
        endHeurList.add(new SelectItem("19:30", "19:30"));
        endHeurList.add(new SelectItem("20:00", "20:00"));
        endHeurList.add(new SelectItem("20:30", "20:30"));
        endHeurList.add(new SelectItem("21:00", "21:00"));
        endHeurList.add(new SelectItem("21:30", "21:30"));
        endHeurList.add(new SelectItem("22:00", "22:00"));
        endHeurList.add(new SelectItem("22:30", "22:30"));
        endHeurList.add(new SelectItem("23:00", "23:00"));
        endHeurList.add(new SelectItem("23:30", "23:30"));
        return endHeurList;
    }
}